package com.camera.handle.util;

/*
引入依赖包
最低SDK版本要求：facebody20191230的SDK版本需大于等于3.0.7。
可以在此仓库地址中引用最新版本SDK：https://mvnrepository.com/artifact/com.aliyun/facebody20191230
<!-- https://mvnrepository.com/artifact/com.aliyun/facebody20191230 -->
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>facebody20191230</artifactId>
    <version>${aliyun.facebody.version}</version>
</dependency>
*/

import com.aliyun.facebody20191230.models.GenerateHumanAnimeStyleResponse;
import com.aliyun.tea.*;

public class GenerateHumanAnimeStyle {

    public static com.aliyun.facebody20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          初始化配置对象com.aliyun.teaopenapi.models.Config
          Config对象存放 AccessKeyId、AccessKeySecret、endpoint等配置
         */
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new com.aliyun.facebody20191230.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // 创建AccessKey ID和AccessKey Secret，请参见：https://help.aliyun.com/document_detail/175144.html
        // 如果您使用的是RAM用户的AccessKey，还需要为子账号授予权限AliyunVIAPIFullAccess，请参见：https://help.aliyun.com/document_detail/145025.html
        // 从环境变量读取配置的AccessKey ID和AccessKey Secret。运行代码示例前必须先配置环境变量。
        String accessKeyId = ConstantUtils.aliyunAccessKeyId;
        String accessKeySecret = ConstantUtils.aliyunAccessKeySecret;
        com.aliyun.facebody20191230.Client client = GenerateHumanAnimeStyle.createClient(accessKeyId, accessKeySecret);
        com.aliyun.facebody20191230.models.GenerateHumanAnimeStyleRequest generateHumanAnimeStyleRequest = new com.aliyun.facebody20191230.models.GenerateHumanAnimeStyleRequest()
                .setImageURL("https://hihooo-kaca-shanghai.oss-cn-shanghai.aliyuncs.com/20240721174454_1.jpg")
                .setAlgoType("hongkong");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // 复制代码运行请自行打印 API 的返回值
            GenerateHumanAnimeStyleResponse response = client.generateHumanAnimeStyleWithOptions(generateHumanAnimeStyleRequest, runtime);
            // 获取整体结果
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));
        } catch (TeaException error) {
            // 获取整体报错信息
            System.out.println(com.aliyun.teautil.Common.toJSONString(error));
            // 获取单个字段
            System.out.println(error.getCode());
        }
    }
}